home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / util / virus / BBBF107.lha / BBBF107_31 / Programmers / BootblockLibrary.doc next >
Text File  |  1994-06-07  |  13KB  |  379 lines

  1.  
  2.                           Bootblock.library
  3.                              version 3.1
  4.                               3324 bytes
  5.  
  6.                    Released the 26th of June 1993
  7.  
  8.              Programmed by Johan Eliasson, SHI member.
  9.             Copyright © Safe Hex International 1992, 1993, 1994.
  10.  
  11.  
  12. INTRODUCTION
  13. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  14. The Bootblock.library/brainfile is an attempt to make life a little
  15. bit easier for programmers of anti-virus utilities, diskcopy programs,
  16. directory utilities, disk packers and for whoever who wants to check the
  17. bootblock of some device, and of course for you, the user, who are dead-
  18. tired of those %$£&%$& viruses...
  19. The library has some easy-to-use functions to read the brainfile, and to
  20. check a bootblock with it. The brainfile will be kept in memory for
  21. you by the library, so that more than one program can use it simultaneously.
  22. I know this doc is short, but take a look at my CheckDrive.c source
  23. and you will get it. If not, write me a letter!
  24.  
  25. Each bootblock is identified with a checksum of four strategically chosen
  26. longwords.
  27.  
  28. I have about 600+ non-virus-bootblocks that I check every new version
  29. of the brainfile with, and so far there has been no false alarms!
  30.  
  31. Note that this is not a standard auto-doc file. It is typed by hand!
  32.  
  33. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  34. LEGAL STUFF
  35. ~~~~~~~~~~~
  36. The BBBF package is freely distributable as long as all of its files are
  37. included in their original form without additions, deletions, or
  38. modifications of any kind, with the following exception:
  39. If your program uses the Bootblock.library/Bootblock.brainfile then they
  40. may be distributed along with it.
  41. If you use this library in your program you must give credit to SHI (like
  42. the note below) and the programmer in your documentation.
  43. The BBBF package may not be used in a commercial program without written
  44. permission by Safe Hex International.
  45. Only a nominal fee (maximum 6$) may be charged for the distribution of BBBF.
  46. This software is provided "AS IS" without warranty of any kind, either
  47. expressed or implied. By using the BBBF package, you agree to accept the
  48. entire risk as to the quality and performance of the program.
  49.  
  50. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  51. A note about Safe Hex International:
  52.  
  53. If  you   know  a  virus  programmer  you  can  get  a reward of $ 1000 for
  54. supplying  his  name  and  address.  The fact is that the law punishes data 
  55. crime very severely. (5 years in jail in most countries).
  56.  
  57. We  are an international group with more than 250 members  who have started 
  58. trying to stop the spread of virus. Let me give you some example:
  59.  
  60.  
  61.         1. Our motto is: "Safe Hex", who dares do anything else today?".
  62.     2. A virus bank containing all well known virus killer programmes.
  63.     3. We help people to get money back lost by virus infection.
  64.         4. We  write articles about virus problems for 8 magazines.
  65.         5. We release the newest and the best virus killers around.
  66.         6. We have more than 20 "Virus Centers" worldwide  where you 
  67.            can get free virus help by phoning our "Hotline", and the
  68.            newest killers translated n your own language at very little
  69.            cost.
  70.  
  71. For more information contact:
  72.  
  73.         SAFE HEX INTERNATIONAL            (Please  send  a "Coupon-Response 
  74.         Erik Loevendahl Soerensen         International" and a self addres-
  75.         Snaphanevej 10                    sed  envelope, if you want infor-
  76.         DK-4720 Praestoe                  mation about SHI by letter).
  77.         Denmark                             
  78.         Phone: + 45 55 99 25 12
  79.         Fax  : + 45 55 99 34 98
  80.  
  81. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  82. TABLE OF CONTENTS
  83.  
  84. Bootblock.library/ReadBBBF
  85. Bootblock.library/FreeBBBF
  86. Bootblock.library/CheckBoot
  87. Bootblock.library/GetBBBFInfo
  88. Bootblock.library/ListBBBF
  89. Bootblock.library/ReadBoot
  90. Bootblock.library/WriteBoot
  91. Bootblock.library/InstallBoot
  92.  
  93. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  94. Bootblock.library/ReadBBBF
  95.  
  96.   result = ReadBBBF(name);
  97.  
  98.   long     ReadBBBF(char *);
  99.                     A0
  100.  
  101.   DESCRIPTION
  102.     Will read the Bootblock.brainfile from name, and keep it in memory
  103.     for you until you FreeBBBF() it.
  104.  
  105.   INPUTS
  106.     name = "L:Bootblock.brainfile" or wherever you want to load it from.
  107.  
  108.   RESULT
  109.     result = errorcode.
  110.     if result >  0  then result is the code returned by IoErr() in case
  111.                     of an IO error.
  112.     if result =  0  then the brainfile is successfully loaded and
  113.                     everything's fine.
  114.     if result = -1  It was no brainfile...strange...
  115.                 -2  Corrupted brainfile. Someone has fiddled with it.
  116.                 -3  Already loaded by someone else!
  117.                 -4  No memory for brainfile. Free some and try again...
  118.  
  119.  
  120. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  121. Bootblock.library/FreeBBBF
  122.  
  123.   result = FreeBBBF();
  124.  
  125.   void     FreeBBBF(void);
  126.  
  127.  
  128.   DESCRIPTION
  129.     Will free the memory used for the brainfile, ie. unload it.
  130.     If the brainfile is not loaded the function will just return.
  131.     You don't HAVE to do this. If you don't, it will be done when
  132.     the library is flushed.
  133.  
  134.   INPUTS
  135.     none
  136.  
  137.   RESULT
  138.     none
  139.  
  140. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  141. Bootblock.library/CheckBoot
  142.  
  143.   Boot = CheckBoot(buffer,&status);
  144.  
  145.   struct Bootblock *CheckBoot(char *,ULONG);
  146.                               A0     A1
  147.  
  148.   DESCRIPTION
  149.  
  150.   INPUTS
  151.     buffer = simply the bootblock that you want to check.
  152.     status = address of an ULONG. Status will afterwards contain one 
  153.              of the following values:
  154.              -1 : Error - The brainfile is not loaded.
  155.               0 : The bootblock is unknown.
  156.               1 : The bootblock is a virus! Kill it!
  157.               2 : The bootblock is not bootable...
  158.  
  159.   RESULT
  160.     Boot    Bootblock struct that contains the name of the bootblock etc.
  161.             If status != 1 then Boot will be NULL.
  162.  
  163.   NOTES
  164.     If the bootblock is a virus, then you'll have to append ' virus!' to
  165.     the name from the Bootblock struct. It saved me quite a lot of bytes
  166.     in the brainfile. 200 ' virus!' would be 1400 bytes...
  167.     I hope you don't mind! 8-)
  168.  
  169. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  170. Bootblock.library/GetBBBFInfo
  171.  
  172. result = GetBBBFInfo(&virus,version);
  173.  
  174. long     GetBBBFInfo(USHORT,char[30]);
  175.                      A0       A1
  176.  
  177.   DESCRIPTION
  178.  
  179.   INPUTS
  180.     virus   = will be the number of viruses known to this brainfile.
  181.     version = string that will contain the brainfile version-string,
  182.               without the '$VER: '.
  183.  
  184.   RESULT
  185.    result   If result == -1 then the brainfile is not loaded.
  186.             If success then result will be 0.
  187.  
  188.  
  189. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  190. Bootblock.library/ListBBBF
  191.  
  192. Boot = ListBBBF()
  193.  
  194. struct Bootblock *ListBBBF(void)
  195.  
  196.   DESCRIPTION
  197.     This function returns the pointer to the first Bootblock structure.
  198.     Useful for listing all known bootblocks etc.
  199.  
  200.   INPUTS
  201.     none
  202.  
  203.   RESULT
  204.     Boot   Pointer to the first Bootblock structure, or
  205.            NULL == the brainfile is not loaded.
  206.  
  207. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  208. Bootblock.library/ReadBoot
  209.  
  210. result = ReadBoot(drive,buffer);
  211.  
  212. ULONG    ReadBoot(ULONG,char *);
  213.                   D0    A0
  214.  
  215.   DESCRIPTION
  216.  
  217.     This function will read the bootblock from the desired drive,
  218.     using the trackdisk.device and CMD_READ.
  219.  
  220.   INPUTS
  221.  
  222.     drive  = drive number (0-3)
  223.  
  224.     buffer = the destination of the bootblock. Must be at least 1024
  225.              bytes. Note that it must be in chip ram if running
  226.              under kickstart V36 or below.
  227.  
  228.   RESULT
  229.  
  230.     result = either NULL = success,
  231.              or an errorcode returned by IoErr(),
  232.              Can occur during the OpenDevice() (see <exec/errors.h>
  233.              or the bootread (see <devices/trackdisk.h>)
  234.              It can also be 103 (out of memory).
  235.  
  236. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  237. Bootblock.library/WriteBoot
  238.  
  239. result = WriteBoot(drive,buffer);
  240.  
  241. ULONG    WriteBoot(ULONG,char *);
  242.                   D0    A0
  243.  
  244.   DESCRIPTION
  245.  
  246.     This function will write the bootblock to the selected drive.
  247.  
  248.   INPUTS
  249.  
  250.     drive  = drive number (0-3)
  251.  
  252.     buffer = the bootblock. Note that it must be in chip ram if running
  253.              under kickstart V36 or below.
  254.  
  255.   RESULT
  256.  
  257.     result = either NULL = success,
  258.              or an errorcode returned by IoErr(),
  259.              Can occur during the OpenDevice() (see <exec/errors.h>
  260.              or the bootwrite (see <devices/trackdisk.h>)
  261.              It can also be 103 (out of memory).
  262.  
  263. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  264. Bootblock.library/InstallBoot
  265.  
  266. result = InstallBoot(drive,bootnumber);
  267.  
  268. long   = InstallBoot(ULONG,USHORT)
  269.                      D0    D1
  270.  
  271.   DESCRIPTION
  272.  
  273.     This function will install an AmigaDOS bootblock to the selected drive.
  274.  
  275.   INPUTS
  276.  
  277.     drive : drive number (0-3)
  278.  
  279.     bootnumber : 0 = 1.x OFS
  280.                  1 = 1.3 FFS
  281.                  2 = 2.0 OFS
  282.                  3 = 2.0 FFS
  283.                  4 = 2.0 OFS International
  284.                  5 = 2.0 FFS International
  285.                  6 = 3.0 OFS DirCache
  286.                  7 = 3.0 FFS DirCache
  287.  
  288.   RESULT
  289.  
  290.     result : either NULL = success,
  291.              or an errorcode returned by IoErr(),
  292.              Can occur during the OpenDevice() (see <exec/errors.h>
  293.              or the bootwrite (see <devices/trackdisk.h>)
  294.              It can also be 103 (out of memory),
  295.              or -99 = illegal bootnumber (must be 0 - 7).
  296.  
  297. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  298.  
  299. LIBRARY HISTORY
  300. ~~~~~~~~~~~~~~~
  301.  
  302. Version 0.9 beta
  303. ~~~~~~~~~~~~~~~~
  304. First version.
  305.  
  306. Version 0.91 beta
  307. ~~~~~~~~~~~~~~~~~
  308. Removed all non-virus bootblocks from the brainfile upon request from
  309. Erik Loevendahl Soerensen. Now you will only be alerted if the bootblock
  310. contains a virus, anti-virus, or any other suspicious resident program.
  311. This is for speed and so that the user won't be bothered with messages
  312. like 'This bootblock is the MegaSuperDemoLoader 32.84' all the time.
  313. The GetBBBFInfo() function is changed accordingly.
  314. I have tried to clean up this doc a bit too. There were a few obvious
  315. mistakes that I guess you spotted.
  316. BBBF now knows 171 original viruses, and a vast number of clones.
  317.  
  318. Version 0.92 beta (15.10.92)
  319. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  320. V 0.91 didn't recognize the Chameleon (little Sven) virus correctly.
  321. Instead of adding a short piece of code to deal with that, I rewrote
  322. the complete brainfile-system, so it will be easier to add new viruses
  323. to the brainfile from now on. As a result of that, the Bootblock structure
  324. has changed a bit. Also, ReadBBBF() and CheckBoot() are a little bit slower,
  325. and the brainfile is 656 bytes bigger......but a lot safer!
  326. BBBF now knows 164 original viruses, and a vast number + 7 clones.
  327.  
  328. Version 0.93 beta (05.11.92)
  329. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  330. Bug fix: If the brainfile-reading was interrupted due to lack of memory,
  331.          the already allocated memory would not be freed correctly. 
  332.  
  333. Version 1.0 (11.11.92)
  334. ~~~~~~~~~~~~~~~~~~~~~~
  335. New function - ReadBoot().
  336. I also optimized the library down to 2876 bytes!
  337.  
  338. Version 1.01 (12.12.92)
  339. ~~~~~~~~~~~~~~~~~~~~~~~
  340. Now you don't HAVE to free the memory with FreeBBBF() when you exit.
  341. If you don't, it will be freed automagically when the library is flushed.
  342.  
  343. Version 2.00 (16.12.92)
  344. ~~~~~~~~~~~~~~~~~~~~~~~
  345. New function - WriteBoot().
  346.  
  347. I learned that OpenLibrary() is case-sensitive. And I have spelled
  348. Bootblock.library with a capital B... so if your OpenLibrary() fails,
  349. that might be the cause...
  350.  
  351. Version 3.00 (02.03.93)
  352. ~~~~~~~~~~~~~~~~~~~~~~~
  353. New function - InstallBoot()
  354.  
  355. Version 3.1 (26.06.93)
  356. ~~~~~~~~~~~~~~~~~~~~~~
  357. Corrected the version-string as you can see.
  358. Changed a few other internal things.
  359.  
  360.  
  361. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  362.  
  363. Please, I need your opinions! Even if you have no complaints nor ideas
  364. it's nice just to hear that it works... 8-)
  365. Send new viruses, ideas, threats and harddrives to:
  366.  
  367.              Johan Eliasson             Phone: +46 11 169138
  368.              Bäckgatan 6
  369.              60358 Norrköping
  370.              SWEDEN
  371.  
  372. Thanks goes to Magnus Holmgren and Tommy Hallgren for helping out with my
  373. C problems, Tommy Hallgren and Mats Erlandsson for testing!
  374. Erik Loevendahl Soerensen at SHI for all his support.
  375. John Lohmeyer, whose Interpret.library I used as a model when designing
  376. this library. Thanks guys!
  377.  
  378. END OF DOC.
  379.